package com.kj.report.rest;

import com.kj.report.model.Device;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kj.report.service.DeviceService;

/**
 * Device的路由接口服务
 * 
 * @author 
 *
 */
@RestController
public class DeviceRest {

	/** DeviceService服务 */
	@Autowired
	private DeviceService deviceService;

	/**
	 * 通过id查询Device数据的方法
	 * @param id
	 * @return
	 */
	@GetMapping(value = "/Device/{id}", produces = {"application/json;charset=UTF-8"})
	public String findOne(@PathVariable(name="id") Long id) {
		return deviceService.findOne(id);
	}
	
	/**
	 * 插入Device属性不为空的数据方法
	 * @param
	 * @return
	 */
	@PostMapping(value = "/Device", produces = {"application/json;charset=UTF-8"})
	public String save(Device value) {
		return deviceService.saveNotNull(value);
	}
	
	/**
	 * 更新Device属性不为空的数据方法
	 * @param
	 * @return
	 */
	@PutMapping(value = "/Device", produces = {"application/json;charset=UTF-8"})
	public String update(Device value) {
		return deviceService.updateNotNullById(value);
	}
	
	/**
	 * 通过id删除Device数据方法
	 * @param id
	 * @return
	 */
	@DeleteMapping(value = "/Device/{id}", produces = {"application/json;charset=UTF-8"})
	public String delete(@PathVariable(name="id") Long id) {
		return deviceService.deleteById(id);
	}
}
